Pushes value onto the top of target, a stack
stack_push(target, value) -> bool| Name | Type |
|---|---|
target | stack |
value | element |
bool
Pushes value onto the top of target, a stack<T> - a container with only ONE end anyone may ever touch. Returns true if it fit, false if target was already full (nothing is pushed - target never crashes or corrupts, it just stops growing).
target is a real fixed-size vector that holds up to N items - N is target's own declared capacity (/// @capacity, default 8 if untagged, same rule every other container on this manual uses). If the return value is ignored, target simply stops accepting new items until something is popped; check it only when the game needs to react to "no room left."
stack<T> has no [i] indexing - unlike array<T>/list<T>/grid<T>, the top is the only item you can ever reach directly. Declare the variable list<T> instead if you need to look inside it by index or search it.
/// @type {stack<int>}
var history = [];
stack_push(history, 1);
var added = stack_push(history, 2); // true - there was room



target is a real fixed-size vector of T items, up to N - N is target's own declared capacity (`/// @capacity`, default 8 if untagged). This checks target.full() before ever calling push_back, the identical safety check list_add makes - an author who never checks the return value still cannot crash their own game by pushing one item too many. O(1).